/**
 * 冒泡排序
 * @param {*} arr
 */
function bubbling(arr) {
  let temp = null
  for (let i = 0, len = arr.length; i < len; i++) {
    let flag = false
    for (let j = 0, len1 = arr.length - i; j < len1; j++) {
      if (arr[j] > arr[j + 1]) {
        temp = arr[j]
        arr[j] = arr[j + 1]
        arr[j + 1] = temp
        temp = null
        flag = true
      }
    }
    if (!flag) break
    else console.error(i, arr)
  }
  return arr
}

console.log(bubbling([1, 2, 5, 7, 8, 0, 9]))
